/*
 * hcsr04.h
 *
 *  Created on: May 21, 2021
 *      Author: kirk_
 */

#ifndef HCSR04_H_
#define HCSR04_H_

#include "kdl.h"
#include "kdl_pin.h"

typedef struct _HCSR04_t {
	KDL_Pin_t Trig, Echo;
	uint32_t Ticks;
} HCSR04_t;

#define HCSR04_TimeOut 6000000U

void HCSR04_Init(
		HCSR04_t* khcsr,
		GPIO_TypeDef* Tport,
		uint16_t Tpin,
		GPIO_TypeDef* Eport,
		uint16_t Epin
		);

uint32_t HCSR04_Measure(HCSR04_t * khcsr);

uint16_t HCSR04_GetDistance(HCSR04_t * khcsr);

#endif /* HCSR04_H_ */
